﻿using Model;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class UserDb //用于保存 链接服务器的sql语句
    {
        public List<Model.UserInfo> User = new List<UserInfo>
        {
            new UserInfo { UserName = "zhangsan" ,PassWord = "5524", ID = 20200001,Email = "2563050@qq.com" },
            new UserInfo { UserName = "wanger" ,PassWord = "0506", ID = 20200002,Email = "2530525@qq.com" },
            new UserInfo { UserName = "lisi" ,PassWord = "0205", ID = 20200003,Email = "2530245@qq.com" },
            new UserInfo { UserName = "lili" ,PassWord = "0000", ID = 20200004,Email = "2530025@qq.com" }
        };
    }
    /// <summary>
    /// 查找用户
    /// </summary>
    public class UserDAO
    {
        /// <summary>
        /// 查找用户
        /// </summary>
        /// <param name="userName">姓名</param>
        /// <param name="Password">密码</param>
        /// <returns></returns>
        public Model.UserInfo SelectUser(string userName, string Password)   //根据 ui 选择返回一个user
        {
            Model.UserInfo user = null;
            UserDb us = new UserDb();
            List<UserInfo> userlist = us.User;
            foreach (var userInfo in userlist)
            {
                if (userInfo.UserName==userName&&userInfo.PassWord==Password)
                {
                    user = userInfo;
                }
            }
            return user;
        }
    }
    /// <summary>
    /// 首次登录
    /// </summary>
    public class ScoreDAO 
    {
        /// <summary>
        /// 首次登录
        /// </summary>
        /// <param name="userName">姓名</param>
        /// <param name="value">增加积分值</param>
        public void UpdateScore(string userName, int value)
        {

        }
    }
}
